<template>
    <div class="box">
      <span>登录</span>
      <div class="content1">
        <el-input v-model="phoneNumber"  placeholder="用户名/手机号" style="width: 300px;margin: 20px 0;"  clearable />
        <el-input v-model="password"  placeholder="密码"  style="width: 300px;" show-password clearable />
      </div>
      <div class="content2">
        <el-button v-for="button in buttons" :key="button.text" :type="button.type" link @click="ForgePassWord">
        {{ button.text }}
        </el-button>
      </div>
      <div class="footer">
        <el-button class="button" type="primary" @click="Login">登录</el-button>
        <el-button class="button" type="primary" @click="Register">注册</el-button>
      </div>
    </div>
  </template>
  
<script setup>
import { ref, } from 'vue'
import { useRouter } from "vue-router";
const router = useRouter();
const todos=ref([])

const phoneNumber = ref('')
const password = ref('')

const buttons = [
  { type: 'primary', text: '忘记密码' },
]

// 登录
const Login =()=>{
    // 重定义值
  let phoneNumbers = phoneNumber.value
  let passwords = password.value
  let todo = { id: Date.now(), phoneNumbers,passwords,};
  todos.value = todo
  console.log(todos.value)

  const msg =  phoneNumbers !==''&&passwords!==''
  if(msg){
      alert('登录成功')
      router.push({ path: "/" });
    }else{
      alert('账号或密码错误')
    }
}

// 注册
const Register=()=>{
  router.push({ path: "/register" });
}
// 忘记密码
const ForgePassWord=()=>{
  router.push({ path: "/forgepassword" });
}
  
</script>
  
<style lang="scss" scoped>
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  .box {
    width: 500px;
    height: 300px;
    border: 2px solid skyblue;
    margin: 50px auto;
    border-radius: 10px;
    span{
      display: block;
      font-size: 30px;
      text-align: center;
      color: skyblue;
    }
    .content1{
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: center;
      margin: 5px 0;
    }
    .content2{
      display: flex;
      justify-content: end;
      margin-right: 95px;
      margin-top: 10px;
    }
    .footer{
      display: flex;
      justify-content: space-around;
      align-items: center;
      .button{
        width: 100px;
        margin-top: 30px;
      }
    }
  }
  </style>